#ifndef __CURRENT_SENSER_H
#define __CURRENT_SENSER_H

#include "at32f415_wk_config.h"
#include "wk_adc.h"
#include "wk_system.h"

#define CURRENT_SENSER_ADC_MAX 4096 // ADC分辨率 12bit
#define CURRENT_SENSER_ADC_REF 3.3  // 参考电压
#define CURRENT_SENSER_OFFSET 1.667f // 偏置
#define CURRENT_SENSER_GAIN 50.0f   // 增益
#define CURRENT_SENSER_R 0.010f     // Ohm

#define ADC_BUF_NUM 5

extern uint16_t adc_raw_buff[ADC_BUF_NUM][4];

uint8_t CurrentSenser_Init(void);
uint8_t CurrentSenser_get_ADC(uint8_t phare, uint16_t *adc_raw);
uint8_t CurrentSenser_get_current(uint8_t phare, uint16_t *adc_raw, float *current);
void CurrentSenser_calibrate(void);

void it_get_adc(void);

#endif
